#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int mod=998244353,inf=0x3f3f3f3f3f3f3f3f;
const int N=2e4+10,M=2e5+10;
mt19937 rnd(time(0));
int p[N],cnt1,cnt2,n=1.9e4;
int x;
vector<pair<int,int>>ans;
void rotate(int l)
{
	ans.push_back({1,l});
	assert(1<=l);
	int r=l+x-1;
	assert(r<=n);
	int v=p[l];
	cnt1++;
	for ( int i = l ; i < r ; i++ )p[i]=p[i+1];
	p[r]=v;
}
void swp(int x)
{
	ans.push_back({2,x});
	assert(1<=x);
	assert(x+1<=n);
	cnt2++;
	swap(p[x],p[x+1]);
}

void solve0()
{
	x=2;
	for ( int i = 1 ; i <= n ; i++ )
		for ( int j = i-1 ; j >= 1 ; j-- )
			if(p[j]>p[j+1])rotate(j);
	cout << 2 << " " << ans.size() << endl;
	for ( auto x:ans )cout << x.first << " " << x.second << endl;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("rotate.in","r",stdin);
	freopen("rotate.out","w",stdout);

//	for ( int i = 1 ; i <= n ; i++ )p[i]=i;
//	shuffle(p+1,p+1+n,rnd);
	
	cin >> n;
	for ( int i = 1 ; i <= n ; i++ )cin >> p[i];
	if(n<=2.5e3)return solve0(),0;
	
	if(n<=1.7e4)x=60;
	else x=100;
	
	for ( int i = n ; i >= x ; i-- )
	{
		int pi;
		for ( int j = 1 ; j <= n ; j++ )
			if(p[j]==i)pi=j;
		while(pi+x-1<=i)
		{
			rotate(pi);
			pi=pi+x-1;
		}
		int r=i,l=i-x+1;assert(l<=pi&&pi<=r);
		while(pi!=i)
		{
			rotate(l);
			if(pi==l)pi=r;else pi--;
		}
	}
	for ( int i = 1 ; i < x ; i++ )
		for ( int j = i-1 ; j >= 1 ; j-- )
			if(p[j]>p[j+1])swp(j);
	for ( int i = 1 ; i <= n ; i++ )assert(p[i]==i);
	cerr << cnt1 << " " << cnt2 << endl;
	assert(cnt1+cnt2<=1.9e6);
	
	cout << x << " " << ans.size()<< endl; 
	for ( auto x:ans )cout << x.first << " " <<  x.second << endl;
	
	return 0;
}


